# P4 ## People * Andrew Adair Comminos * Tristan Rice * Benson Li ## What We have created a 3D island defense game. Advanced functionality items: - Advanced rendering effects - A multipass shader is used to provide glow effects for select objects in the scene. - Shaders - A custom shader is used for the water that surrounds the island. - Particle systems - The physics system manages collisions, velocity, position, and acceleration of particles, which spawn on object destruction, damage, and as bullets. - Each particle has a lifetime as well. - Procedural modeling - The island terrain is procedurally generated as a lattice with uniform elevation noise, with a parametric gaussian-like falloff around the edges. - Collision detection - A prop system is used for collidable objects and particles in the scene, resolving collisions between an arbitrary number of objects in the world. - Animation - Smooth animations are used in the implementation of the following features; - Turret targeting - Camera movement - Enemy movement (rolling along the axis perpendicular to their surface and velocity) - Destructible objects ## How - The water shader models specular wave highlights sinusoidally with respect to time, distance from the origin, and angle about the origin to mimick rising and falling wave crests. - The water also raises and falls in phase with the wave crests with respect to time. - The island terrain is generated by assembling a lattice of vertices that are subject to uniform elevation noise, and fall off using a gaussian-like distribution around the edges. - Collision detection is done each frame using the following algorithm: For each physics object ("prop") 'o' in the world: If the island/terrain height is greater than o's y position, move up and 'bounce' depending on the bounciness parameter. For each other object 'o`' that collides with the object in the world (where collision is defined by intersecting spherical colliders): If o` has collided with o in this frame already, skip. Subtract the projection of o's velocity onto the normal between o` and o from o's velocity. Exert a normal force on o's velocity linearly proportional to the distance between o and o`. Set the new position of o using its current velocity multiplied by delta time. Prominent classes: - Entity - Interface for 3D objects in the scene that need to update each frame, and may have a physics prop attached. - Prop - Class for managing physics interactions in a scene - Map - Manages a list of entities - Wave - Represents a swarm of monsters - Monster - An entity that targets the goal objective in the map ## Howto The object of this game is to hold off the blob invaders for as long as possible from reach your cube. Your cube has 10 lives and you start with $10,000 in which you can build two types of defenses: walls and turrets (No one knows how you have ammunition for the turrets or bricks for that matter). Walls can withstand multiple hits from blobs and are your best defense against the rolling menace. Turrets are you only source of offense but are destroyed instantly by any damage. To create either, click on a location square to build either. Defenses may be refunded for partial cost and walls may be repaired. Walls may be stacked upon each other and turrets maybe be placed on top of walls. The game’s camera is controlled by mouse movements as well as the arrow keys on a keyboard. Enemies arrive in waves which are initiated by the player – before each wave, the player is given time to fortify their defenses. ## Sources * THREE.js documentation and examples * http://www.simppa.fi/blog/the-new-particle/# INSPIRATION: This game was inspired by the many flash-based defend-your-castle as well as the tower defense games that are on the internet. Gameplay elements such as defending a central point and utilizing towers and walls to slow and destroy invaders were borrowed from these games.